﻿SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[bht_GroupExtensions](
	[GroupId] [int] NOT NULL,
	[Extension] [nvarchar](400) NOT NULL,
 CONSTRAINT [PK_bht_GroupExtensions] PRIMARY KEY CLUSTERED 
(
	[GroupId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO



CREATE PROCEDURE [dbo].[bhp_NemoGroupExtensions]
AS
BEGIN

	SELECT
		*
	FROM
		bht_GroupExtensions
	
END


GO


CREATE PROCEDURE [dbo].[bhp_NemoRecordDelete]
	@Table		NVARCHAR(100),
	@RecordId	INT,
	@UserId		INT
AS
BEGIN

	
	DECLARE @Q NVARCHAR(1000)
	
	SET @Q = 'UPDATE ' + @Table + ' SET del=1, mtime=GETDATE(), muser=' + CAST(@UserId as NVARCHAR(10)) + ' WHERE idx=' + CAST(@RecordId as NVARCHAR(10))
	EXEC sp_executesql @Q
	
	
END


GO




CREATE PROCEDURE [dbo].[bhp_NemoRecordIdentChange]
	@Table		NVARCHAR(100),
	@RecordId	INT,
	@Ident		NVARCHAR(400),
	@UserId	INT
AS
BEGIN

	
	DECLARE @Q NVARCHAR(1000)
	
	SET @Q = 'UPDATE ' + @Table + ' SET identyfikator=''' + @Ident + ''', mtime=GETDATE(), muser=' + CAST(@UserId as NVARCHAR(10)) + ' WHERE idx=' + CAST(@RecordId as NVARCHAR(10))
	EXEC sp_executesql @Q
	
	
END



GO
